package sqlite;

import java.io.File;
import java.io.IOException;

/**
 * Created by GanJc on 2015/12/7.
 */
public class FileDemo {

    public static void main(String[] args) throws IOException {
        File file = new File(UPLOAD_DIR);
        if(file.isDirectory()){
            ORIGIN_DIR = file.getName();
            System.out.println(ORIGIN_DIR);
            listFiles(file);
        }
        System.out.println("文件夹数量：" + dirCount);
        System.out.println("文件数量：" + fileCount);
    }

    private static String UPLOAD_DIR = "H:\\牛名网";
    private static String ORIGIN_DIR  ;
    private static String DOWNLOAD_DIR = "H:\\temp\\test";
    private static int dirCount = 0;
    private static int fileCount = 0;

    public static void listFiles(File file) throws IOException {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                listFiles(f);
            }
            dirCount++;
        } else {
            String aPath = file.getAbsolutePath();
            aPath = aPath.replace(UPLOAD_DIR,"");
            String savePath = DOWNLOAD_DIR + File.separator + ORIGIN_DIR + aPath;
            System.out.println(savePath);
            fileCount++;
        }
    }

}
